package org.ccams.dao;

import org.ccams.domain.TGoods;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import java.util.List;
import org.ccams.util.PageParameter;
public class TGoodsDAO extends SqlMapClientDaoSupport {
	
	/**
	 * 返回指定页码的数据
	 * @return
	 */
	@SuppressWarnings({ "unchecked", "deprecation" })
	public  List<TGoods> getTGoods(PageParameter pageParmeter){		
		return getSqlMapClientTemplate().queryForList("t_goods.getTGoodsByPage", pageParmeter);
	}
	/**
	 * 返回记录总数
	 * @return
	 */
	public int getCount(){
		return (Integer)getSqlMapClientTemplate().queryForObject("t_goods.getTGoodsCount");
	}
	
	
	/**
	 * 返回所有商品
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public  List<TGoods> getAllTGoods(){		
		return getSqlMapClientTemplate().queryForList("t_goods.getAllTGoods");
	}
	/**
	 * 添加商品
	 * @param t
	 * @return
	 */
	public int addTGoods(TGoods t ){
		return getSqlMapClientTemplate().update("t_goods.addTGoods", t);
	}
	/**
	 * 更新商品
	 * @param t
	 * @return
	 */
	public int updateTGoods(TGoods t ){
		return getSqlMapClientTemplate().update("t_goods.updateTGoods", t);
	}
	/**
	 * 删除商品
	 * @param id
	 * @return
	 */
	public int deleteTGoods(String id){
		return getSqlMapClientTemplate().update("t_goods.deleteTGoods", id);
	}
	/**
	 * 返回查询条件的数据
	 * @return
	*/	
	@SuppressWarnings({ "unchecked", "deprecation" })
	public  List<TGoods> getTGoodsByPageAndKey(PageParameter pageParmeter){		
		return getSqlMapClientTemplate().queryForList("t_goods.getTGoodsByPageAndKey", pageParmeter);
	}
	 
	/**
	 * 统计查询条件的数据
	 * @return
	*/ 		
	public int getTGoodsCountByKey(String keywords){
		return (Integer)getSqlMapClientTemplate().queryForObject("t_goods.getTGoodsCountByKey",keywords);
	}	
	
}